/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-08-28     huger       the first version
 */
#ifndef APPLICATIONS_FOC_PID_H_
#define APPLICATIONS_FOC_PID_H_

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "bsp\bsp.h"

typedef struct
{
    float_t P_Gain;
    float_t I_Gain;
    float_t D_Gain;

    float_t Max_Output;
    float_t Min_Output;

    float_t err;
    float_t err_last;
    float_t integral;

}CURRENT_PID_DEF;

typedef struct
{
    float_t P_Gain;
    float_t I_Gain;
    float_t D_Gain;

    float_t err;
    float_t err_last;
    float_t integral;

    float_t Max_Output;
    float_t Min_Output;
}SPEED_PID_DEF;

typedef struct
{
    float_t P_Gain;
    float_t I_Gain;
    float_t D_Gain;

    float_t err;
    float_t err_last;
    float_t integral;

    float_t Max_Output;
    float_t Min_Output;

}POSI_PID_DEF;


extern CURRENT_PID_DEF Current_D_PID;
extern CURRENT_PID_DEF Current_Q_PID;
extern SPEED_PID_DEF Speed_Pid;
extern POSI_PID_DEF  Posi_Pid;

void PID_Init(void);
void Current_PID_Calc(float_t ref_temp,float_t fdb_temp,float_t* out_temp,CURRENT_PID_DEF* current_pid_temp);
void Speed_Pid_Calc(float_t ref_temp,float_t fdb_temp,float_t* out_temp,SPEED_PID_DEF* current_pid_temp);
void Posi_Pid_Calc(float_t ref_temp,float_t fdb_temp,float_t* out_temp,POSI_PID_DEF* current_pid_temp);


#ifdef __cplusplus
}
#endif /* __cplusplus */



#endif /* APPLICATIONS_FOC_PID_H_ */
